package com.systop.domain.to;

import com.systop.entity.Consignee;
import com.systop.entity.Goods;
import com.systop.entity.Order;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Description: TODO
 * @Author: jsj
 * @Date: 2023/3/9
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderTo implements Comparable<OrderTo>{
    private String orderNo;
    //商品总数
    private Integer goodsNum;
    //商品总价
    private BigDecimal goodsSum;

    //订单状态
    private Integer orderStatus;

    //收货地址
    private Consignee consignee;
    //订单商品信息
    private List<Order> goodsList;


    @Override
    public int compareTo(OrderTo o) {
        if(o.goodsList == null || o.goodsList.size()==0){
            return 0;
        }
        Date createTime = o.getGoodsList().get(0).getCreateTime();
        if (createTime.getTime() > this.getGoodsList().get(0).getCreateTime().getTime()) {
            return 1;
        } else if (createTime.getTime() < this.getGoodsList().get(0).getCreateTime().getTime()) {
            return -1;
        } else {
            return 0;
        }
    }
}
